package com.gxitsky.async.design.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;

import java.util.List;
import java.util.Map;

/**
 * @author gxing
 * @desc TODO
 * @date 2022/8/12
 */
@Data
@Configuration
public class PropertiesConfig {

    @Value("#{systemProperties['os.name']}")
    private String osName;

    @Value("#{ T(java.lang.Math).random() * 100}")
    private Integer intRandomNumber;

    @Value("#{ T(java.lang.Math).random() * 100.0}")
    private Double doubleRandomNumber;

    @Value("#{webConfig.beanValue}")
    private String beanValue;

    @Value("classpath:demo.txt")
    private Resource demoFile;

    @Value("${boolean.value:true}")
    private boolean booleanValue;

    @Value("${int.value:16}")
    private int intValue;

//    @Value("${cluster.node}")
//    private List<String> nodes;

//    @Value("#{'${some.name}'.trim().split(',')}")
    @Value("#{'${some.name}'}")
    private List<String> someName;

    @Value("#{'${some.hobby:read/run/food}'.trim().split('/')}")
    private List<String> hobby;

    @Value("${test.array}")
    private String[] testArray;

    @Value("#{${key.secret}}")
    private Map<String,String> maps;

    @Value("#{${appid.secret:{'appid10':'Secret10','appid20':'Secret20'}}}")
    private Map<String,String> mapWithDefault;
}
